package cn.edu.lcu.cs.javalearning.net;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;

public class WasteYard extends Thread {
    private String serverName = "localhost";
    private int port = 9000;

    private Socket client;

    public WasteYard() throws IOException {
        client = new Socket(serverName, port);
    }

    @Override
    public void run() {
        try (ObjectInputStream in = new ObjectInputStream(client.getInputStream())) {
            while (true) {
                Ore ore = (Ore) in.readObject();
                System.out.println(ore);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws IOException {
        new WasteYard().start();
    }

}
